package com.qf.index.gcrdo;

import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import cn.hutool.db.ds.DSFactory;
import lombok.SneakyThrows;

import java.util.List;

/**
 * @Author: 葛成瑞
 * @Date: 2025/5/16 17:22
 */
public class SpTableMergeData {
    @SneakyThrows
    public static void main(String[] args) {
        // 进行拆分表格如果表 word_and_code_set_map_new  的code_set 字段是多个拆成多个

        Db use = Db.use(DSFactory.get("localdb"));
        String table = "word_and_code_set_map_new";
        List<Entity> query = use.query("select * from " + table + " where check_final is null ");
        for (Entity entity : query) {
            String tongyiBack = entity.getStr("tongyi_back");
            String type = entity.getStr("type");
            String pathway = entity.getStr("pathway");
            String drug = entity.getStr("drug");
            String disease = entity.getStr("disease");
            String genge = entity.getStr("genge");
            if (tongyiBack.equals("是")) {
                entity.set("check_final", "是");
            } else {
                if (type.equals("通路") && StringUtil.isNotNull(pathway)) {
                    entity.set("check_final", pathway);
                }
                if (type.equals("药物")) {
                    entity.set("check_final", drug);
                }
//                if (type.equals("疾病") && StringUtil.isNotNull(disease)) {
//                    entity.set("check_final", disease);
//                }
                if (type.equals("疾病")) {
                    entity.set("check_final", tongyiBack);
                }
                if (type.equals("基因") && StringUtil.isNotNull(genge)) {
                    entity.set("check_final", genge);
                }
            }
            use.update(entity, Entity.create(table).set("id", entity.getStr("id")));

        }

    }
}
